import { defineStore } from "pinia"
import { ref } from "vue"
import type {Member} from "@/types/member";

export const useMemberStore = defineStore(
  "member",
  () => {
    //会员信息
    const profile = ref<Member>()
    // 保存会员信息
    const setProfile = (val: Member) => {
      profile.value = val
    }
    // 清理会员信息
    const clearProfile = () => {
      profile.value = undefined
    }
    return {
      profile,
      setProfile,
      clearProfile,
    }
  },
  //TODO:持久化
  {
	// 网页端配置
	//  persist: true
	// 小程序配置
	persist:{
		storage:{
			getItem(key){
				return uni.getStorageSync(key)
			},
			setItem(key,value){
				uni.setStorageSync(key,value)
			}
		}
	}
 }
)
